Thực đơn
Node.js Ví dụĐây là phiên bản hello world HTTP Server trên Node.js:
var http = require('http');http.createServer(function (request, response) { response.writeHead(200, {'Content-Type': 'text/plain'}); response.end('Hello World\n');}).listen(80);console.log('Server running at http://localhost:80/');
Đoạn mã sau là một máy chủ TCP hoạt động trên cổng 7000 và in ra chuỗi 'hello' trên mỗi kết nối:
var net = require('net');net.createServer(function (stream) { stream.write('hello\r\n'); stream.on('end', function () { stream.end('goodbye\r\n'); }); stream.pipe(stream);}).listen(7000);
Thực đơn
Node.js Ví dụLiên quan
Node.jsTài liệu tham khảo
WikiPedia: Node.js http://github.com/joyent/libuv http://github.com/ry/node/blob/master/AUTHORS http://groups.google.com/group/nodejs http://groups.google.com/group/nodejs-dev http://engineering.linkedin.com/nodejs/blazing-fas... http://www.marketwatch.com/story/nodejs-selected-b... http://mashable.com/2011/03/10/node-js/ http://www.nodeconf.com/ http://ofps.oreilly.com/titles/9781449398583/forwa... http://shop.oreilly.com/product/0636920015956.do